<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="用户ID" prop="userId" v-if="false" class="item">
        <el-input
          v-model="queryParams.userId"
          placeholder="请输入用户ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工作时长" prop="workHours" class="item">
        <el-input
          v-model="queryParams.workHours"
          placeholder="请输入每日工作时长"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="state">
        <el-select v-model="queryParams.state" placeholder="请选择状态" clearable size="small" class="item">
          <el-option
            v-for="dict in stateOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否超时" prop="isTimeOut" class="item">
        <el-select v-model="queryParams.isTimeOut" placeholder="请选择是否超时" clearable size="small">
          <el-option
            v-for="dict in isTimeOutOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['work:process:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['work:process:edit']"
        >修改</el-button> 
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-check"
          size="mini"
          :disabled="finishState"
          @click="handleFinshCheck"
          v-hasPermi="['work:process:finished']"
        >完成</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-check"
          size="mini"
          :disabled="finishState"
          @click="handleCheck"
          v-hasPermi="['work:process:checked']"
        >提交审核</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['work:process:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['work:process:export']"
        >导出</el-button>
      </el-col>
      
	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="processList" border @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键ID" align="center" prop="itemId" v-if="false"/>
      <el-table-column label="用户ID" align="center" prop="userId" v-if="false"/>
      <el-table-column label="用户名称" align="center" prop="user.nickName"/>
      <el-table-column label="工作时长" align="center" prop="workHours" />
      <el-table-column label="文件时长" align="center" prop="fileHours" />
      <el-table-column label="文件时长ID" align="center" prop="fileId" v-if="false"/>
      <!-- <el-table-column label="文本工时" align="center" prop="textHours" /> -->
      <el-table-column label="所属组别" align="center" prop="workUserGroup" />
      <el-table-column label="状态" align="center" prop="state" :formatter="stateFormat" />
      <el-table-column label="是否超时" align="center" prop="isTimeOut" :formatter="isTimeOutFormat" />
      <el-table-column label="开始时间" align="center" prop="startTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束时间" align="center" prop="finishTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.finishTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际完成时间" align="center" prop="realFinishTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.realFinishTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['work:process:edit']"
          >修改</el-button> 
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['work:process:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-back"
            @click="handleBackCheck(scope.row)"
            v-hasPermi="['work:process:back']"
          >退回</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-download"
            @click="handleImport(scope.row)"
            v-hasPermi="['work:process:uploadFile']"
          >附件</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改任务分配对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" :close-on-click-modal="false" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="任务ID" prop="workId" v-if="false">
              <el-input v-model="form.workId" placeholder="请输入任务ID" v-if="false"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="userIds" label="人员姓名" filterable="true">
              <el-select v-model="form.userIds" clearable  multiple style="width:100%" @change="selectUserChange">
                <el-option v-for="item in usersOptions" :key="item.userId" :label="item.nickName" :value="item.userId" :disabled="item.states == 1" ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属组别" prop="groups">
              <el-select v-model="form.groups" multiple  filterable  placeholder="请选择" prop="groupType" style="width:100%">
                <el-option v-for="item in groupTypeOptions" :key="item.id" :label="item.name" :value="item.code" :disabled="item.states == 1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="fileId" label="文件时长" filterable="true">
              <el-select v-model="form.fileId"  style="width:100%">
                <el-option v-for="item in filesOptions" :key="item.fileId" :label="item.name" :value="item.fileId" :disabled="item.state == 1" ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="录入次数" prop="number" v-if="isedit" >
              <el-input v-model="form.number" type="number" oninput="if(value>60)value=60" v-if="isedit"  onkeypress='return( /[\d]/.test(String.fromCharCode(event.keyCode)))' placeholder="请输入录入次数" maxlength="2" style="width:100%"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="任务时限">
              <el-date-picker
                v-model="dateWorkRange"
                size="small"
                name="se"
                style="width: 100%"
                value-format="yyyy-MM-dd"
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                @change="selectUserChange"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24"  v-if="isPeopleWorkLineShow" >
                <AnalyzeEasyLineCharts class="middleTwo" :handleOfficeLineCharts="handlePeopleLineCharts" :chart-data="peopleCompositeLineCharts" />
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 完成任务分配对话框 -->
    <el-dialog :title="titleComplete" :visible.sync="openComplete" width="500px" :close-on-click-modal="false" append-to-body> 
      <el-form ref="finshForm" :model="finshForm" :rules="finshRules" label-width="100px">    
         <el-form-item label="任务ID" prop="workId" v-if="false">
          <el-input v-model="finshForm.itemId" placeholder="请输入任务ID" v-if="false"/>
          <el-input v-model="finshForm.workId" placeholder="请输入任务ID" v-if="false"/>
        </el-form-item>
        <el-form-item label="完成时间">
          <el-date-picker
            v-model="finshForm.realFinishTime"
            type="date"
            placeholder="选择日期"
            :picker-options="pickerOptions0"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitComplete()" 
            v-hasPermi="['work:process:uploadFile']">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 上传文件 -->
     <el-dialog :title="titleUpload" :visible.sync="openUpload" width="800px" :close-on-click-modal="false"  append-to-body>
       <el-tabs v-model="activeName">
        <el-tab-pane id="processUserUpload" label="上传" name="first">
          <el-upload ref="upload" 
          :limit="1" 
          :data="uploadData" 
          :headers="headers" 
          :action="url" 
          :disabled="isUploading" 
          :on-progress="handleFileUploadProgress" 
          :on-success="handleFileSuccess" 
          :auto-upload="false" drag>
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">
            将文件拖到此处，或
            <em>点击上传</em>
          </div>
      </el-upload>
        <el-button type="primary" @click="submitFileForm" style="display:block;margin:0 auto;marginTop:1em">上 传</el-button>
        </el-tab-pane>
        <el-tab-pane label="附件查看" name="second">
           <el-row :gutter="10" class="mb8">
           </el-row>
          <el-table v-loading="loading" :data="fileLists" border @selection-change="handleSelectionFileChange">
                <el-table-column type="selection" width="55" align="center" />
                <el-table-column label="文件ID" align="center" prop="id" v-if="false"/>
                <el-table-column label="文件URL" align="center" prop="url" v-if="false"/>
                <el-table-column label="文件名称" align="center" prop="name"/>
                <el-table-column label="文件类型" align="center" prop="type" :formatter="stateFileTypeFormat" />
                <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                  <template slot-scope="scope">
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="handleFileDownload(scope.row)"
                    >下载</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-delete"
                      @click="handleFileDelete(scope.row)"
                      v-hasPermi="['work:file:remove']"
                    >删除</el-button>
                    <!-- <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-check"
                      @click="handleComplete(scope.row)"
                      v-hasPermi="['work:process:complete']"
                    >预览</el-button> -->
                  </template>
                </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <!-- 
       -->
      <div slot="footer" class="dialog-footer">
        <!-- <el-button type="primary" @click="submitFileForm">确 定</el-button> -->
        <el-button @click="openUpload = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {getUsers,listHours,groupList} from "@/api/work/process";
import { listProcess, getProcess, delProcess, addProcessAndResolve,updateProcess, exportProcess,
 completeStates,selectFiles,deleteFiles,downloadFile,completeCheckStates } from "@/api/work/user";
import { getToken } from '@/utils/auth';
import { download } from '@/utils/ruoyi';
import AnalyzeEasyLineCharts from '../../../statistics/linecharts/AnalyzeEasyLineChart';
import { queryPeopleCompositeTotalLineCharts } from "@/api/statistics/work/composite";
import echarts from 'echarts';
export default {
  name: "Process",
  components: { 
    AnalyzeEasyLineCharts
  },
  data() {
    return {
      fileLists: [{
        id:'',
        url: "",
        name: '',
        type: ''
      }],
      // 完成的时间选择控制 只能选择当天日期之后的日子
      pickerOptions0: {
          // disabledDate(time) {
          //   return time.getTime() < Date.now() - 8.64e7;
          // }
      },  
      completeData:{
        itemIds:[],
        workId:'',
        realFinishTime:''
      },
      itemId: null,
      itemIds:null,
      dateRange:[],
      dateWorkRange: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 选中状态数组
      states:[],
      //是否编辑
      isedit:true,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 非完成禁用
      finishState:true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 任务分配表格数据
      processList: [],
       //文本工时
      textHoursOptions:[],
      //文件类型
      textFileTypeOptions: [],
      //组别
      groupTypeOptions: [],
       // 文件时长选项
      filesOptions:[],
      //用户信息
      usersOptions:[],
      // 弹出层标题
      title: "",
      titleComplete: "",
      titleUpload: "",
      // 上传参数
      // 上传标签页
      activeName: 'first',
      // 是否禁用上传
      isUploading: false,
      // 设置上传的请求头部
      headers: { Authorization: 'Bearer ' + getToken()},
      uploadData: {
        tableId: null
      },
      // 上传的地址
      url: process.env.VUE_APP_BASE_API+"/work/process/user/upload",
      //路径
      baseURL:  process.env.VUE_APP_BASE_API,
      // 是否显示弹出层
      open: false,
      openComplete: false,
      openUpload: false,
      // 状态字典
      stateOptions: [],
      // 是否超时字典
      isTimeOutOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        workId: null,
        workHours: null,
        state: null,
        isTimeOut: null,
        startTime: null,
        finishTime: null,
        realFinishTime: null,
        deptId:null,
        workType:"0"
      },
      //人员近30天工作
      peopleCompositeLineCharts:{},
      //是否显示人员统计
      isPeopleWorkLineShow: false,
      //查询统计图参数
      queryTotal:{
          userId: null,
          beginTime: null,
          endTime: null
      },
      // 表单参数
      form: {},
      finshForm: {},
      finshRules: {},
      // 表单校验
      rules: {
        userIds: [
          { required: true, message: "用户ID不能为空", trigger: "blur" }
        ],
        groups:[
          { required: true, message: "所属组别不能为空", trigger: "blur" }
        ],
        fileId: [
          { required: true, message: "文件时长ID不能为空", trigger: "blur" }
        ],
        startTime: [
          { required: true, message: "开始时间不能为空", trigger: "blur" }
        ],
        finishTime: [
          { required: true, message: "结束时间不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.queryParams.workId = this.$route.query.workId;
    this.queryParams.deptId = this.$route.query.deptId;
    this.form.workId = this.$route.query.workId;
    this.getList();
    // this.handleGroupList();
    this.getDicts("work_file_state").then(response => {
      this.stateOptions = response.data;
    });
    this.getDicts("sys_yes_no").then(response => {
      this.isTimeOutOptions = response.data;
    });
    this.getDicts("work_text_hours").then(response => {
      this.textHoursOptions = response.data;
    });
    this.getDicts("sys_file_type").then(response => {
      this.textFileTypeOptions = response.data;
    });
    
  },
  activated(){
    if(this.$route.query.workId){
      this.queryParams.workId = this.$route.query.workId;
      this.queryParams.deptId = this.$route.query.deptId;
      this.form.workId = this.$route.query.workId;
      this.getList();
    }
  },
  methods: {
    /** 查询任务分配列表 */
    getList() {
      this.loading = true;
      listProcess(this.addDateRange(this.queryParams, this.dateRange)).then(
        (response) => {
        this.processList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 添加日期范围
    addFinishDateRange(params, dateRange) {
      var search = params;
      search.startTime = "";
      search.finishTime = "";
      if (null != dateRange && '' != dateRange) {
        search.startTime = dateRange[0];
        search.finishTime = dateRange[1];
      }
      return search;
    },
    /** 查询附件列表 */
    getFileList() {
      this.loading = true;
      selectFiles(this.itemId).then((response) => {
        this.fileLists = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 状态字典翻译
    stateFormat(row, column) {
      return this.selectDictLabel(this.stateOptions, row.state);
    },
    // 文件类型翻译
    stateFileTypeFormat(row, column) {
      return this.selectDictLabel(this.textFileTypeOptions, row.type);
    },
    // 是否超时字典翻译
    isTimeOutFormat(row, column) {
      return this.selectDictLabel(this.isTimeOutOptions, row.isTimeOut);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.openComplete = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        dateRange:[],
        itemId: null,
        // workId: null,
        userIds: null,
        userId: null,
        workHours: null,
        fileHours: null,
        fileId: null,
        textHours: null,
        state: null,
        isTimeOut: null,
        startTime: null,
        finishTime: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        realFinishTime:null,
        number:1
      };
      this.dateWorkRange = null;
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange=[];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.itemId)
      this.single = selection.length!==1
      this.multiple = !selection.length
      this.states = selection.map(item => item.state);
      if(this.multiple){
        this.finishState = true;
      }else{
          this.finishState = this.states.some( (item,i) =>{
            return  item == 5
          })
      }
    },
     /** 查询未录入用户下拉 */
    getUsersList(deptId) {
      getUsers(deptId).then((response) => {
        this.usersOptions = response.data;
      });
    },
    getFilesList(deptId){
      listHours(deptId).then((response) => {
        this.filesOptions = response.data;
      });
    },
    handleSelectionFileChange(selection){
      this.id = selection.map(item => item.id)
      this.uri = selection.map(item => item.uri)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.getFilesList(this.queryParams.deptId);
      this.getUsersList(this.queryParams.deptId);
      this.handleGroupList();
      this.queryParams.startTime = this.$route.query.startTime;
      this.queryParams.finishTime = this.$route.query.finishTime;
      this.dateWorkRange = [this.$route.query.startTime,this.$route.query.finishTime];
      this.open = true;
      this.isPeopleWorkLineShow = false;
      this.peopleCompositeLineCharts = {};
      this.title = "添加任务分配";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.isedit = false;
      const itemId = row.itemId || this.ids
      this.getUsersList(this.queryParams.deptId);
      this.handleGroupList();
      this.getFilesList(this.queryParams.deptId);
      this.isPeopleWorkLineShow = false;
      this.peopleCompositeLineCharts = {};
      getProcess(itemId).then(response => {
        this.form = response.data;
        this.dateWorkRange = [response.data.startTime, response.data.finishTime];
        this.form.groups = response.groupIds;
        this.form.userIds = [response.userId];
        this.open = true;
        this.title = "修改任务分配";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.workId = this.queryParams.workId;
          if (this.form.itemId != null) {
            updateProcess(this.addFinishDateRange(this.form, this.dateWorkRange)).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            this.form.workType = 0
            addProcessAndResolve(this.addFinishDateRange(this.form, this.dateWorkRange)).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
        
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const itemIds = row.itemId || this.ids;
      this.$confirm('是否确认删除任务分配编号为"' + itemIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delProcess(itemIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    // 删除文件操作
    handleFileDelete(row){
      const id = row.id || this.id;
      this.$confirm('是否确认删除任务分配编号为"' + id + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return deleteFiles(id);
        }).then(() => {
          this.getFileList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    // 下载文件
    handleFileDownload(row){
      const id = row.id || this.id;
      const url = row.uri || this.uri;
      window.location.href = this.baseURL+url;
    },
    // // 完成状态
    // submitComplete(){
    //   this.finshForm.workId = this.queryParams.workId;
    //   console.log("传递参数："+this.finshForm.itemId+"--"+this.finshForm.realFinishTime+"--"+this.finshForm.workId);
    //   completeStates(this.finshForm.itemId,this.finshForm.realFinishTime,this.finshForm.workId).then(response => {
    //       if (response.code === 200) {
    //         this.msgSuccess("完成任务成功");
    //         this.openComplete = false;
    //         this.getList();
    //       }
    //    })
    // },
    // 完成操作
    // handleComplete(row){
    //     this.finshForm.itemId = row.itemId || this.ids;
    //     this.openComplete = true;
    //     this.titleComplete = "完成任务";
    // },
    // 完成操作
    handleFinshCheck(row){
        this.itemIds = row.itemId || this.ids;
        completeCheckStates(this.itemIds,"5").then(response => {
          if (response.code === 200) {
            this.msgSuccess("提交成功");
            this.openComplete = false;
            this.getList();
          }
       })
    },
    // 退回
    handleBackCheck(row){
       this.itemIds = row.itemId ;
        completeCheckStates([this.itemIds],"2").then(response => {
          if (response.code === 200) {
            this.msgSuccess("提交成功");
            this.openComplete = false;
            this.getList();
          }
       })
    },
    //提交审核
    handleCheck(row){
        this.itemIds = row.itemId || this.ids;
        completeCheckStates(this.itemIds,"1").then(response => {
          if (response.code === 200) {
            this.msgSuccess("提交成功");
            this.openComplete = false;
            this.getList();
          }
       })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有任务分配数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportProcess(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    },
    /** 上传按钮操作 */
    handleImport(row) {
      const itemId = row.itemId || this.ids;
      this.titleUpload = "上传与附件";
      this.openUpload = true;
      this.uploadData.tableId = itemId;
      this.itemId = itemId;
      this.getFileList();
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      // console.log(event,'event')
      this.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.openUpload = false;
      this.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "上传结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    handleGroupList(){
      groupList().then((response) => {
        this.groupTypeOptions = response.data;
      });
    },
    // 查询人员最近30天工作曲线
    handlePeopleLineCharts(params){
        let userName = "";
        queryPeopleCompositeTotalLineCharts(params).then(response => {
            let newObject = {
                xdata:[],
                ydata:[],
                zdata:[],
                adata:[],
                bdata:[]
            }  
            response.forEach((item,index)=>{
                newObject.xdata.push(item.time)
                newObject.ydata.push(item.totalValue)
                userName = item.name;
            })
            newObject.bdata.push(userName+":近30天工作量曲线（H）");
            this.peopleCompositeLineCharts = newObject
        });
    },
    //查询人员工作曲线图
    queryPeopleWorkLine(){
      if(null==this.form.userIds||"" == this.form.userIds){
            this.$message({
              showClose: true,
              message: '请选人人员信息',
              type: 'warning'
            });
            return;
      }
      if(null==this.dateWorkRange){
            this.$message({
              showClose: true,
              message: '请选择任务时限',
              type: 'warning'
            });
            return;
      }
      let userIds = this.form.userIds;
      let userId  = userIds[userIds.length-1];
      this.queryTotal.userId = userId;
      this.queryTotal.beginTime = this.dateWorkRange[0];
      this.queryTotal.endTime = this.dateWorkRange[1];
      this.handlePeopleLineCharts(this.queryTotal);
      this.isPeopleWorkLineShow = true;
    },
    //监听选择用户事件
    selectUserChange(value){
      this.queryPeopleWorkLine();
    },
  }
};
</script>
<style>
.el-upload-list__item-name{
    font-size: 16px;
}
#processUserUpload .el-upload-dragger{
  display:block;
  margin:0 auto;
  margin-top:1em;
  width: 760px;
  height: 180px;
}
</style>